package com.amat0urheu.util;

//import com.google.common.collect.ImmutableSet;
//import com.google.common.io.Closeables;
//import com.google.inject.Module;
//import org.jclouds.ContextBuilder;
//import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
//import org.jclouds.openstack.nova.v2_0.NovaApi;
//import org.jclouds.openstack.nova.v2_0.domain.Server;
//import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import java.io.IOException;
import java.util.Set;

public class JCloudsNova {

    public static void test() throws IOException {

//        Iterable<Module> modules = ImmutableSet.<Module>of(new SLF4JLoggingModule());
//        String provider = "openstack-nova";
//        String identity = "admin:admin"; // 项目管理员和用户
//        String credential = "123123";// 用户密码
//
//        NovaApi  novaApi = ContextBuilder.newBuilder(provider)
//                .endpoint("http://192..168.201.17:5000/v3/")//API地址
//                .credentials(identity, credential)
//                .modules(modules)
//                .buildApi(NovaApi.class);
//        Set<String> regions = novaApi.getConfiguredRegions();
//        System.out.println("======准备连接");
//        try {
//            System.out.println("======开始监听");
//            for (String region : regions) {
//                ServerApi serverApi = novaApi.getServerApi(region);
//
//                for (Server server : serverApi.listInDetail().concat()) {
//                    System.out.println("  " + server);
//                }
//            }
//
//            System.out.println("======准备关闭");
//            Closeables.close(novaApi, true);
//        } catch (Exception e) {
//            e.printStackTrace();
//        } finally {
//            System.out.println("======准备关闭");
//            Closeables.close(novaApi, true);
//        }
    }

}